package com.yhzc.dao;

import com.yhzc.domain.User;
import com.yhzc.utils.JdbcUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class UserDao {
    private JdbcTemplate template = new JdbcTemplate(JdbcUtils.getDataSource());

    public User login(User user) {
        String sql = "select * from user where username = ? and password = ?";
        //System.out.println(sql);
        try {
            User query = template.queryForObject(sql, new BeanPropertyRowMapper<User>(User.class), user.getUsername(), user.getPassword());
            return query;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
